package message.test.test;

import com.p6spy.engine.common.P6Util;
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

import java.util.concurrent.TimeUnit;

/**
 * .
 *
 * @author sunhao(sunhao.java@gmail.com)
 * @version 1.0 2017/12/26 上午12:56
 */
public class LodsveCustomLineFormat implements MessageFormattingStrategy {
    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql) {
        return String.format("sunhao execute '%s' at '%s' use connection id is '%s'! Spend time is '%s S'!", P6Util.singleLine(sql), now, connectionId, TimeUnit.NANOSECONDS.toSeconds(elapsed));
    }
}
